package com.woniu.mashangxiadan.restaurant.controller;

import com.woniu.mashangxiadan.common.Result;
import com.woniu.mashangxiadan.form.*;
import com.woniu.mashangxiadan.model.OrderInfo;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiImplicitParam;
import io.swagger.annotations.ApiImplicitParams;
import io.swagger.annotations.ApiOperation;
import org.springframework.web.bind.annotation.*;

import java.util.ArrayList;

@RestController
@Api(tags = "商家的Api", description = "提供商家相关的 Rest API")
@RequestMapping("/restaurant")
public class RestaurantController {

    @PostMapping("/login")
    @ApiOperation("商家登录(分为老板，厨师和前台收银员)")
    public Result login(String phone, String password) {
        return Result.success();
    }

    @GetMapping("/getDesks")
    @ApiOperation("获取桌位")
    public Result getDesks(Integer restaurantId) {
        return Result.success();
    }

    @PostMapping("/addDesk")
    @ApiOperation("添加桌位")
    public Result addDesk(@RequestBody DeskForm deskForm) {
        return Result.success();
    }

    @PutMapping("/updateDesk")
    @ApiOperation("修改桌位")
    public Result updateDesk(@RequestBody DeskUpdateForm deskUpdateForm) {
        return Result.success();
    }

    @PutMapping("/deleteDesk")
    @ApiOperation("删除桌位")
    public Result deleteDesk(Integer deskId) {
        return Result.success();
    }

    @GetMapping("/getDishes")
    @ApiOperation("获取店里菜品")
    public Result getDishes(Integer restaurantId) {
        return Result.success();
    }

    @PostMapping("/addDish")
    @ApiOperation("添加菜品")
    public Result addDish(@RequestBody DishForm dishForm) {
        return Result.success();
    }

    @PutMapping("/updateDish")
    @ApiOperation("修改菜品")
    public Result updateDish(@RequestBody DishUpdateForm dishUpdateForm) {
        return Result.success();
    }

    @PutMapping("/deleteDish")
    @ApiOperation("删除菜品")
    public Result deleteDish(Integer dishId) {
        return Result.success();
    }

    @GetMapping("/getHistoryOrders")
    @ApiOperation("查询历史订单")
    @ApiImplicitParams({
            @ApiImplicitParam(name = "RestaurantId", value = "商家的id", dataType = "int")
    })
    public Result getHistoryOrders(Integer RestaurantId) {
        return Result.success(new ArrayList<OrderInfo>());
    }

    @PutMapping("/refundOrder")
    @ApiOperation("已完成的订单退款")
    @ApiImplicitParams({
            @ApiImplicitParam(name = "orderId", value = "用户退款订单id", dataType = "int")
    })
    public Result refundOrder(Integer orderId) {
        return Result.success();
    }

    @PostMapping("/checkOrder")
    @ApiOperation("用户线下支付，商家点击完成订单")
    @ApiImplicitParams({
            @ApiImplicitParam(name = "orderId", value = "商家结束用户支付订单id", dataType = "int")
    })
    public Result checkOrder(Integer orderId) {
        return Result.success();
    }

    @PostMapping("/finishOrder")
    @ApiOperation("用户离开未支付，商家结束订单")
    @ApiImplicitParams({
            @ApiImplicitParam(name = "orderId", value = "用户未支付订单id", dataType = "int")
    })
    public Result finishOrder(Integer orderId) {
        return Result.success();
    }

    @DeleteMapping("/cancelOrder")
    @ApiOperation("用户离开长时间未提交订单或者用户用餐时出现意外需要取消订单，由商家取消订单")
    @ApiImplicitParams({
            @ApiImplicitParam(name = "orderId", value = "要取消的订单id", dataType = "int")
    })
    public Result cancelOrder(Integer orderId) {
        return Result.success();
    }

    @PutMapping("/repayOrder")
    @ApiOperation("之前未支付订单的用户返回支付后，点击完成订单")
    @ApiImplicitParams({
            @ApiImplicitParam(name = "orderId", value = "要支付的订单id", dataType = "int")
    })
    public Result repayOrder(Integer orderId) {
        return Result.success();
    }

    @PutMapping("/serveDish")
    @ApiOperation("厨师点击准备上菜")
    @ApiImplicitParams({
            @ApiImplicitParam(name = "orderId", value = "订单id", dataType = "int"),
            @ApiImplicitParam(name = "orderDishId", value = "订单菜品id", dataType = "int")
    })
    public Result serveDish(Integer orderId, Integer orderDishId) {
        return Result.success();
    }

    @DeleteMapping("/cancelDish")
    @ApiOperation("与用户协商退菜")
    @ApiImplicitParams({
            @ApiImplicitParam(name = "orderId", value = "订单id", dataType = "int"),
            @ApiImplicitParam(name = "orderDishId", value = "订单菜品id", dataType = "int")
    })
    public Result cancelDish(Integer orderId, Integer orderDishId) {
        return Result.success();
    }

    @PutMapping("/updateRestaurant")
    @ApiOperation("更新餐厅信息")
    @ApiImplicitParams({
            @ApiImplicitParam(name = "restaurantForm", value = "餐厅更新的信息", dataType = "RestaurantForm")
    })
    public Result updateRestaurant(@RequestBody RestaurantForm restaurantForm) {
        return Result.success();
    }

    @PutMapping("/becomePremium")
    @ApiOperation("餐厅成为高级用户，会员月数")
    @ApiImplicitParams({
            @ApiImplicitParam(name = "restaurantId", value = "餐厅Id", dataType = "int"),
            @ApiImplicitParam(name = "month", value = "会员月数", dataType = "int")
    })
    public Result becomePremium(Integer restaurantId, Integer month) {
        return Result.success();
    }

}
